﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Data;
using System.Text;
namespace IHISCETeim.Web.MachineSys.FTradeModel.ImortDate
{
    public partial class FTradeCatheringAddImport : PageBase
    {
        protected override string DWZRef
        {
            get
            {
                return "FTradeCatheringListEasyUI";
            }
        }

        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.none };
            }
        }

        protected int FTradeID
        {
            get
            {

                return GetRequestValue<int>("FTradeID", 0);
            }
        }

        private FTradeReceivablesInfo _objFx = null;

        protected FTradeReceivablesInfo objTrade
        {
            get
            {
                if (_objFx == null)
                    _objFx = FTradeReceivablesController.GetByFTradeID(FTradeID);
                return _objFx;
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "add")
            {
                addmenu();
            }
        }
        private void addmenu()
        {
            FTradeCatheringInfo obj = Request.SerializableObject<FTradeCatheringInfo>();
            obj.SourceTag = "人工";
            obj.RealName = base.User.RealName;
            obj.State = "未冲完";
            obj.IsAdjustable = false;
            if (string.IsNullOrEmpty(obj.KuanXiangLeiXing))
            {
                ErrorJson("请选择款项类型.");
                return;
            }
            int id = FTradeCatheringController.Add(obj);
            if (id > 0)
            {
                //跳转参数
                string msg = "已成功收款,进入冲帐界面...";
                string tabTitle = "冲帐";
                string taburl = "FTradeModel/ImortDate/FTradeBalanceAddImport.aspx?FCatheringId=" + id.ToString() + "&JiHao="+objTrade.JiHao+"&FTradeID=" + FTradeID.ToString();
                string tabrelId = "FTradeBalanceAdd";
                SuccessOpenNavTab(msg, tabTitle, taburl, tabrelId);
                //SuccessJson("新增成功");
            }
            else
            {

                ErrorJson("新增失败");
            }

        }
    }
}